package com.yunxi.controller.sys;

import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.LoginInfo;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.sys.pojo.InfomationVO;
import com.yunxi.sys.service.InfomationDubboService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *pa
 * @author* @since 2019-09-17
 */
@RestController
@RequestMapping("/admin/infomation")
@Api(tags = "pms:infomation", description = "接口")
public class InfomationController {
   private static final Logger logger = LoggerFactory.getLogger(InfomationController.class);

   @Autowired
   InfomationDubboService infomationDubboService;

   @GetMapping("/page")
   @ApiOperation(value = "查询分页")
   public ApiResult page(InfomationVO infomationVO, Integer pageNum, Integer pageSize ,@CurrentUser LoginInfo loginInfo) throws Exception {
      return ResponseUtil.ok(infomationDubboService.findPageByVO(infomationVO, pageNum, pageSize,loginInfo));
   }

   @GetMapping("/list")
   @ApiOperation(value = "查询列表")
   public ApiResult list(InfomationVO infomationVO) throws Exception {
      return ResponseUtil.ok(infomationDubboService.listByVo(infomationVO));
   }

   @GetMapping("/load")
   @ApiOperation(value = "读取单个")
   public ApiResult load(InfomationVO infomationVO, @CurrentUser LoginInfo loginInfo) throws Exception {
      return ResponseUtil.ok(infomationDubboService.getById(infomationVO.getInfoId()));
   }

   @PostMapping("/save")
   @ApiOperation(value = "保存信息")
   public ApiResult save(@RequestBody InfomationVO infomationVO, @CurrentUser LoginInfo loginInfo) throws Exception {
      infomationDubboService.saveOrUpdate(infomationVO,loginInfo);
      return ResponseUtil.ok("success");
   }

   @PostMapping("/del")
   @ApiOperation(value = "删除")
   public ApiResult del(@RequestBody List<InfomationVO> infomationVOList) throws Exception {
      infomationDubboService.removeByListVo(infomationVOList);
      return ResponseUtil.ok("success");
   }

/*@PostMapping("/export")
@ApiOperation(value = "导出excel")
public Object export(@RequestParam Map<String,Object> params) throws Exception {
return ResponseUtil.ok(infomationDubboService.findMapByList(params));
}*/
}
